﻿using SketchUpAPI.NET.Objects;
using SketchUpAPI.NET.SketchUp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SketchUpConsole.Examples
{
    public static class CreateCurveAndArc
    {
        public static void Run()
        {
            string writePath = @"ExampleFiles\1.skp";
            string read2022 = @"ExampleFiles\2022.skp";
            string read2 = @"ExampleFiles\2.skp";

            SketchUpApplication.Initialize();
            SketchUpModel skp = SketchUpModel.Create();

            // 创建一段曲线
            Point3D pt1 = new Point3D(0, 0, 0);
            Point3D pt2 = new Point3D(100.0.ToModel(), 0, 0);
            Point3D pt3 = new Point3D(200.0.ToModel(), 100.0.ToModel(), 0);
            Edge e1 = new Edge(pt1, pt2);
            Edge e2 = new Edge(pt2, pt3);
            Curve cu = new Curve(e1, e2);
            skp.Entities.Add(cu);

            // 创建圆弧
            Arc circle = Arc.CreateCircle(pt1, 50.0.ToModel());
            Arc arc = Arc.Create((pt2 + pt3) / 2, pt2, pt3);
            skp.Entities.Add(circle, arc);

            skp.Save(writePath);
            skp.Dispose();
            SketchUpApplication.Terminate();
        }
    }
}